import { createStore, createLogger } from 'vuex'

const isProduction = process.env.NODE_ENV === 'production';
const files = require.context("./modules", false, /\.ts$/);
const modules: { [x: string]: any; } = {};
files.keys().forEach((key: string) => {
  modules[key.replace(/(\.\/|\.ts)/g, "")] = files(key).default;
});
Object.keys(modules).forEach((key)=>{
  modules[key]["namespaced"] = true;
  modules[key]["plugins"] = isProduction ? [] : [createLogger()]
})
const store = createStore({
  modules
});
export default store;
